package stu.day9_day18;

import java.util.ArrayDeque;

public class LeetCode155 {

    ArrayDeque<Integer> stack = new ArrayDeque<>();


    public void push(int val) {
        stack.addLast(val);
    }

    public void pop() {
        stack.removeLast();
    }

    public int top() {
        return stack.getLast();
    }

    public int getMin() {
        int minValue = stack.getFirst();
        for (int value : stack) {
            if (value < minValue) {
                minValue = value;
            }
        }
        return minValue;


    }
}
